﻿<%@ Import Namespace="System.Runtime.InteropServices" %>
<%@ Import Namespace="System.Text" %>
<%@ Import Namespace="HHG.Common" %>
<%@ Import Namespace="System.IO" %>
<%@ Page Language="C#"  %>

<script runat="server">

	protected void Page_Load(object sender, EventArgs e)
	{
		Response.ContentType = "application/json";
		var config = GetCrawlerConfig();


		var files = System.IO.Directory.GetFiles(config.VideosPath) ;

		var list = new List<FileInfo>();
		foreach (var item in files)
		{
			list.Add(new FileInfo {  Name=Path.GetFileNameWithoutExtension(item)} );

		}

		Response.Write(list.SerializeObject());



		Response.End();
	}

	private class FileInfo {

		public string Name { get; set; }
	}


	private CrawlerConfig GetCrawlerConfig()
	{
		var filePath = Server.MapPath("~/Config/config.json");
		return System.IO.File.ReadAllText(filePath, Encoding.GetEncoding("gbk")).DeserializeObject<CrawlerConfig>();

	}

	protected class CrawlerConfig
	{
		public string CrawlerExe { get; set; }
		public string VideosPath { get; set; }

	}
</script>

